package com.gm.wj.service;

import com.gm.wj.dao.CourseCategoryDAO;
import com.gm.wj.entity.CourseCategory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *
 */
@Service
public class CourseCategoryService {
    @Autowired
    CourseCategoryDAO courseCategoryDAO;

    public List<CourseCategory> list() {
        Sort sort = Sort.by(Sort.Direction.DESC, "id");
        return courseCategoryDAO.findAll(sort);
    }

    public CourseCategory get(int id) {
        CourseCategory c= courseCategoryDAO.findById(id).orElse(null);
        return c;
    }
}
